package com.sniff.atp.modules.test.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sniff.atp.modules.test.mapper.OpsDeleteSkuMapper;
import com.sniff.atp.modules.test.model.DemandReport;
import com.sniff.atp.modules.test.model.OpsDeleteSku;
import com.sniff.atp.modules.test.service.OpsDeleteSkuService;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author macro
 * @since 2023-10-12
 */
@Service
public class OpsDeleteSkuServiceImpl extends ServiceImpl<OpsDeleteSkuMapper, OpsDeleteSku> implements OpsDeleteSkuService {


    @Override
    public boolean create(OpsDeleteSku opsDeleteSku) {
        opsDeleteSku.setCreateTime(new Date());
        opsDeleteSku.setUpdateTime(new Date());
        return save(opsDeleteSku);
    }

    @Override
    public boolean update(Long id, OpsDeleteSku opsDeleteSku) {
        opsDeleteSku.setSkuDeleteId(id);
        opsDeleteSku.setUpdateTime(new Date());
        return updateById(opsDeleteSku);
    }

    @Override
    public Page<OpsDeleteSku> list(OpsDeleteSku opsDeleteSku, Integer pageSize, Integer pageNum) {
        Page<OpsDeleteSku> page = new Page<>(pageNum,pageSize);
        QueryWrapper<OpsDeleteSku> wrapper = new QueryWrapper<>();
        wrapper.lambda()
//                .like(StringUtil.isNotBlank(demandReport.getDemandName()), DemandReport::getDemandName,demandReport.getDemandName())
//                .eq(StringUtil.isNotBlank(demandReport.getDemandType()),DemandReport::getDemandType,demandReport.getDemandType())
//                .eq(StringUtil.isNotBlank(demandReport.getDemandStatus()),DemandReport::getDemandStatus,demandReport.getDemandStatus())
//                .ge(demandReport.getStartTime() != null,DemandReport::getPublishDate,demandReport.getStartTime())
//                .le(demandReport.getEndTime() != null,DemandReport::getPublishDate,demandReport.getEndTime())
                .orderByDesc(OpsDeleteSku::getCreateTime);
        return page(page, wrapper);

    }
}
